#ifndef CONNECTIONWIN_H
#define CONNECTIONWIN_H

#include <winsock.h>
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

class ConnectionWin
{
 public:
  static const int RC_OK = 1, RC_ERROR = -1;

  ConnectionWin();

  int connect(string host, int port);
  string read();
  void write(string data);
  void write(string data, string delim);
  ConnectionWin accept(int port);
  int endAccept();
  void close();
  void setNonblock();
  string readNonblock();

 protected:
  static const int BUFF_LEN = 256, BACKLOG = 10;
  int connSock, serverSock;
  int dataLen;
  char rcvBuff[BUFF_LEN];
  string buffer;
  string delim;
  struct hostent *he;
  struct sockaddr_in my_addr, their_addr;
  int sin_size;
  WSADATA wsaData;
  bool connected, accepting;
  int yes;
};


#endif
